package com.smart_campus.teg.controller;

import com.smart_campus.sys.common.DataGridView;
import com.smart_campus.teg.common.TEGResultObj;
import com.smart_campus.teg.service.ExamService;
import com.smart_campus.teg.vo.ExamVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @aytgor 陈鹏
 * @date 2020/7/1 15:17
 */
@RestController
@RequestMapping("Exam")
public class ExamController {
    @Autowired
    private ExamService examService;

    /**
     * 生成列表分页
     * @param examVo
     * @return DataGridView
     */
    @RequestMapping("ExamList")
    public DataGridView ExamList(ExamVo examVo){
        return examService.getExamList(examVo);
    }

    @RequestMapping("AddEaxm")
    public TEGResultObj AddEaxm(ExamVo examVo){
        try {
            examService.insert(examVo);
            return TEGResultObj.YES;
        } catch (Exception e) {
            return TEGResultObj.NO;
        }
    }

    @RequestMapping("UpdateEaxm")
    public TEGResultObj UpdateEaxm(ExamVo examVo){
        try {
            examService.updateByPrimaryKeySelective(examVo);
            return TEGResultObj.YES;
        } catch (Exception e) {
            return TEGResultObj.NO;

        }
    }

    @RequestMapping("DeleteEaxm")
    public TEGResultObj DeleteEaxm(Integer[] ids){
        try {
            for (Integer integer:ids){
                examService.deleteByPrimaryKey(integer);
            }
            return TEGResultObj.YES;
        } catch (Exception e) {
            return TEGResultObj.NO;
        }
    }

}
